﻿/*************************************************************************
 * Created by OhZee Creative, LLC
 * 2013
 * This code is licensed under Microsoft Public License (Ms-PL)
 * http://opensource.org/licenses/ms-pl
 * http://ozframework.codeplex.com/
 *************************************************************************/

namespace OhZeeCreative.Helpers
{
    using System;

    #if SILVERLIGHT
    using System.Windows.Media;
    #endif

    #if NETFX_CORE
    using Windows.UI;
    #endif

    public static class ColorHelper
    {
        public static double Intensity(this Color color)
        {
            return ((int)color.R + (int)color.G + (int)color.B) / 3.0;
        }

        public static double Lightness(this Color color)
        {
            int max = (int) Math.Max(color.R, Math.Max(color.G, color.B));
            int min = (int) Math.Min(color.R, Math.Min(color.G, color.B));

            return (max + min) * 0.5;
        }

    }
}
